from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from time import sleep
from faker import Faker
from selenium.webdriver.common.by import By

faker = Faker(locale='zh_cn')
name = faker.name()
class QQ:
    def __init__(self,url,driver):
        self.url=url
        self.driver=driver
    def open_driver(self):
        self.driver.get(self.url)
        self.driver.maximize_window()
    def drop(self):
        self.iframe = WebDriverWait(self.driver, 10, 0.5).until(EC.presence_of_all_elements_located((By.TAG_NAME, 'iframe')))
        self.driver.switch_to.frame(self.iframe[0])

    def addUserGroup(self):
        WebDriverWait(self.driver, 10, 0.5).until(EC.presence_of_element_located((By.ID, 'img_out_2257414808'))).click()
    def stop(self):
        self.driver.switch_to.default_content()
        sleep(5)
if __name__ == '__main__':
    driver = webdriver.Chrome()
    c1=QQ(driver=driver,url='https://y.qq.com/portal/pop_login.html')
    c1.open_driver()
    c1.drop()
    c1.addUserGroup()
    c1.stop()

